<?php
class admin_groupModel extends baseModel{
    protected $table = 'admin_group';

    //管理组列表
    public function group_list() {
        return $this->select('','','gid desc');
    }

    //获取权限
    public function get_purview(){
        return api(getApps(),'purview');
    }

    //管理组信息
    public function info($gid) {
        return $this->find('gid='.$gid);
    }

    //获取指定管理组列表
    public function content_list($gid) {
        return $this->select('gid in('.$gid.')','','gid desc');
    }

    //添加管理组
    public function add($data)
    {
        $data['model_purview']=serialize($data['model_purview']);
        return $this->insert($data);
    }
    //编辑管理组
    public function edit($data)
    {
        $condition['gid']=intval($data['gid']);
        $data['model_purview']=serialize($data['model_purview']);
        return $this->update($condition,$data); 
        
    }
    //删除管理组
    public function del($gid)
    {
        //删除关联
        model('admin_relation')->relation_del($gid);
        return $this->delete('gid='.intval($gid)); 
    }

	
}